#include "scriptdocument.h"

ScriptDocument::ScriptDocument(const QString& name) : IDocument(),
    m_valid(true),
    m_dirty(false),
    m_future(false),
    m_name(name),
    m_data(new QTextDocument(this))
{
    connect(m_data, SIGNAL(contentsChanged()),
        this, SIGNAL(dirtyChanged(bool)));
}

ScriptDocument::~ScriptDocument()
{

}

void ScriptDocument::setValid(bool valid)
{
    m_valid = valid;
}

bool ScriptDocument::isValid() const
{
    return m_valid;
}

bool ScriptDocument::isFuture() const
{
    return m_future;
}

bool ScriptDocument::isDirty() const
{
    return m_dirty;
}

QString ScriptDocument::name() const
{
    return m_name;
}

void ScriptDocument::setDirty(bool dirty)
{
    m_dirty = dirty;
}

void ScriptDocument::setFuture(bool future)
{
    m_future = future;
}

void ScriptDocument::rename(const QString& name)
{
    if (m_name != name)
    {
        m_name = name;

        emit nameChanged();
    }
}

QTextDocument* ScriptDocument::data() const
{
    return m_data;
}
